home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / mda_spy.com / SPY.C < prev   
Encoding:
C/C++ Source or Header  |  1980-01-01  |  1.2 KB  |  78 lines

  1. #include "dos.h"
  2. #include "stdlib.h"
  3. #include "windows.h"
  4.  
  5. void spycls(void);
  6. void init(void);
  7. void spystr(char *,char,char);
  8. void spytoa(int,char,char);
  9. void spyarr(char,int,char,char);
  10.  
  11. struct {char car,att;} (far *Video)[25][80] ;
  12.  
  13. #define CAR(LGN,COL) ((*Video)[LGN][COL].car)
  14. #define ATT(LGN,COL) ((*Video)[LGN][COL].att)
  15.  
  16.  
  17. void spycls()
  18.      {
  19.     int i,j;
  20.     init();
  21.     for (i=0;i<25;i++)
  22.         {
  23.         for (j=0;j<80;j++)
  24.           {
  25.             CAR(i,j)=' ';
  26.           ATT(i,j)=0;
  27.           }
  28.          }
  29.     }
  30.  
  31. void spystr(char *string,char l,char c)
  32.     {
  33.     init();
  34.     while(*string)
  35.         {
  36.          CAR(l,c) = *string;
  37.         ATT(l,c) = 0x07;
  38.         if (++c > 79) c = 0;
  39.         if (c == 0)
  40.            if (++l >24)
  41.              {
  42.                 spycls();
  43.              l=0;
  44.              }
  45.         string ++;
  46.         }
  47.     }
  48.  
  49. void spytoa(int x,char l,char c)
  50.     {
  51.     char *string;
  52.     init();
  53.     string=(char *)LocalAlloc(LPTR,10);
  54.     itoa(x,string,10);
  55.     while(*string)
  56.         {
  57.          CAR(l,c) = *string;
  58.         ATT(l,c) = 0x0F;
  59.         if (++c > 79) c = 0;
  60.         if (c == 0)
  61.            if (++l >24)
  62.              {
  63.                 spycls();
  64.              l=0;
  65.              }
  66.         string ++;
  67.         }
  68.     LocalFree((HANDLE)string);
  69.     }
  70.  
  71.  
  72. void init()
  73. {
  74. FP_SEG(Video) = 0xB000;
  75. FP_OFF(Video) = 0x0000;
  76. }
  77.  
  78.